package lib.persistence;

import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import sun.reflect.generics.reflectiveObjects.NotImplementedException;
public class MySqlConnector {
	private MySqlConfiguration config;
	public MySqlConnector(MySqlConfiguration config) {
		this.config = config;
	}
	public MySqlConfiguration getConfiguration() {
		return config;
	}
	public Connection getMySqlConnection() throws ClassNotFoundException, SQLException {
	      Class.forName("com.mysql.jdbc.Driver");
	      String url =  String.format("jdbc:mysql://%s/%s",config.location,config.name);
	      Connection con = DriverManager.getConnection(url,config.username, config.password);
	      return con;
	}
	public Connection getConnection() throws ClassNotFoundException, SQLException {
		return getMySqlConnection();
	}
	
	

}
